#pragma once

#include "my_cleanup.h"
#include "my_queue.h"

typedef void (*my_hook_handler_pt)(void *data);

typedef struct {
    my_hook_handler_pt          handler;
    my_queue_t                  queue;
} my_hook_item_t;

typedef struct {
    my_queue_t                  head;
} my_hook_chain_t;

extern my_hook_chain_t *global_hook_chain;
extern my_hook_chain_t *worker_init_chain;
extern my_hook_chain_t *worker_quit_chain;
extern my_hook_chain_t *tcp_accept_init_chian;
extern my_hook_chain_t *tcp_accept_quit_chian;

void my_hooks_init();

void my_hook_chain_register(my_hook_chain_t *chain,
    my_hook_handler_pt hook_handler);
void my_hook_chain_exec(my_hook_chain_t *chain, void *data);

